import React, { FC, useState } from "react"
import { produce } from "immer"

const immerDemo: FC = () => {
  const [userInfo, setUserInfo] = useState({ name: "shuangyu", age: 21 })
  function changeAge() {
    setUserInfo(
      produce((draft) => {
        draft.age = 20
      })
    )
  }
  return (
    <div>
      <h2>state不可变数据</h2>
      <div>{JSON.stringify(userInfo)}</div>
      <button></button>
    </div>
  )
}
export default immerDemo
